#include <bits/stdc++.h>
// 2025/01/21
// tag: 
// Author: Zhang Muen
using namespace std;

#define int int64_t

int n, h, r, ball[1001][3];

class UF
{
public:
    vector<int> parents;
    int cnt;

    UF(int n)
    {
        cnt = n;
        for (int i = 0; i < n; i++)
            parents.push_back(i);
    };

    int find(int i)
    {
        if (parents[i] != i)
            return parents[i] = find(parents[i]);
        return parents[i];
    }

    void un(int i, int j)
    {
        int ri = find(i), rj = find(j);
        if (ri == rj)
            return;
        parents[ri] = rj;
        cnt--;
    }

    int count()
    {
        return cnt;
    }

    bool connected(int p, int q)
    {
        return find(p) == find(q);
    }
};

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--){
        cin >> n >> h >> r;
        UF UF(n + 2);
        for (int i = 1; i <= n; i++)
            cin >> ball[i][0] >> ball[i][1] >> ball[i][2];
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (pow(ball[i][0] - ball[j][0], 2) + pow(ball[i][1] - ball[j][1], 2) + pow(ball[i][2] - ball[j][2], 2) <= 4 * r * r)
                    UF.un(i, j);
        for (int i = 1; i <= n; i++)
            if (ball[i][2] <= r)
                UF.un(0, i);
        for (int i = 1; i <= n; i++)
            if (ball[i][2] + r >= h)
                UF.un(n + 1, i);
        if (UF.connected(0, n + 1))
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}